func minSubArrayLen(target int, nums []int) int {
    l := 0
    sum := 0
    min := 1000000
    for r:=0; r<len(nums); r++ {
        sum += nums[r]
        for sum >= target {
            if r - l + 1 < min {
                min = r - l + 1
            }
            sum -= nums[l]
            l++
        }
    }
    if min == 1000000 {
        return 0
    }
    return min
}